<?php 
$lati_current = $_GET['lati'];
$longi_current = $_GET['longi'];
$time_now = date("Y-m-d H:i:s");
$id = $_GET['id'];
function storePosition($time_now,$lati_current,$longi_current)
{
	$sql = "INSERT INTO position_data VALUES ('" . $time_now . "','" . $lati_current . "','" . $longi_current . "')";
	$link = mysql_connect('localhost','root','');
	if(!$link)
	{
		die('Erroe:could not make a database link using');
	}
	mysql_select_db('example',$link);
	$resource = mysql_query($sql,$link);
	mysql_close();
}
function location($time_now,$lati_current,$longi_current,$id)
{
	$sql = "UPDATE location SET time = '" . $time_now . "',lati = '" . $lati_current . "',longi = '" . $longi_current . "' WHERE id = '" .$id . "'";
	$link = mysql_connect('localhost','root','');
	if(!$link)
	{
		die('Erroe:could not make a database link using');
	}
	mysql_select_db('example',$link);
	$resource = mysql_query($sql,$link);
	if($resource)
	{
		echo 'stored successfully';
	}
	
}
storePosition($time_now,$lati_current,$longi_current);
location($time_now,$lati_current,$longi_current,$id);

?>